/*******************************************************************************
*   			Impacts of a Large-Scale Parenting Program: 				   *
*					Experimental Evidence from Chile						   *
********************************************************************************


	REQUIRES:	"${dt_final}panel_RR_indexes.dta"
				
				
	CREATES:	${out_tables}/T9A_first_Stage_Allcontrols..xls
				
	WRITEN BY:  Italo Lopez  [italolop@usc.edu]

********************************************************************************
	Prepare data
*******************************************************************************/
	* Load Data 
	use "${dt_final}/panel_RR_indexes.dta", clear

/*******************************************************************************
*   Set macros for regressions
*******************************************************************************/
				

	* Controls
	*-----------------------------------------------------------
	
	macro  def Xvar1 "i.gender i.inc_qtaut_old i.pc_edu_mdsfin hh_mem single num_hermen"  	
	macro  def Xvar2 "i.age_year i.gender i.inc_qtaut_old i.pc_edu_mdsfin hh_mem single num_hermen active_old full_time_old"  	
 	macro  def Xvar3 "i.age_year i.gender i.inc_qtaut_old i.pc_edu_mdsfin hh_mem single num_hermen active_old full_time_old active full_time"  	
	



	xtset CENTRO_SALUD

/*******************************************************************************
	 Table A9: First stage (extended table with all controls)
*******************************************************************************/


	xtset CENTRO_SALUD
	* FS1, FS4 are table 5
	* FS2 and FS4 are table A9

	eststo fs1: xtreg treat2 group2 if x==1, fe i(CENTRO_SALUD)
	eststo fs2: xtreg treat2 group2 $Xvar2 if x==1, fe i(CENTRO_SALUD)

	eststo fs4: xtreg treat3 group3 if x==1, fe i(CENTRO_SALUD)
	eststo fs5: xtreg treat3 group3 $Xvar2 if x==1, fe i(CENTRO_SALUD)

	
label var group2 "NEP-B"
label var group3 "NEP-I"
label var age_year "Child's age at baseline (base: 0-12 mo.)"
label var gender "Girls"
label def genderlab 1 "Boys" 2 "Girls"
label values  gender genderlab
tab age_year
label def age_yearlb 3 "Child's age at baseline (base: 0-12 mo.)"  4 "13-24 mo." 5 "25-36 mo." 6 "37-48 mo." 7 "49-60 mo." 8 "60mo"
label values  age_year age_yearlb

label def inc_qtaut_oldlb 1 "HH Incomes (base: q1)" 2 "q2" 3 "q3" 4 "q4"
label values  inc_qtaut_old inc_qtaut_oldlb

label def pc_edu_mdsfinlb 1 "Caregiver Education (base: Primary)" 2 "High School Dropout" 3 "High School Degree" 4 "College"
label values  pc_edu_mdsfin pc_edu_mdsfinlb

label var inc_qtaut_old "HH Incomes (base: q1)"
label var pc_edu_mdsfin "Caregiver Education (base: Primary)"
label var hh_mem "Number of HH members"
label var single "Single mother"
label var num_hermen "Number of HH members"
label var active_old "Caregiver active at baseline" 
label var full_time_old "Caregiver works full-time at baseline"


	esttab fs2 fs5 using  "${out_tables}/appendix/T9A_first_stage_Allcontrols.csv", replace f ///
			cells("b(fmt(3)star)" "se(fmt(3)par)")  star(* 0.10 ** 0.05 *** 0.01) /// 
			stats(r2  N , fmt(2 0 ) labels("R-squared" "Observations" )) legend			label				
	


	 

